
/*
	EffectSprite( .cOrigin = cOrigin,
					.iSprite = SPRITE_STEAM1,
					.fScale = 1.0,
					.iBrightness = 200
				);
*/
PM_FUNC_NORM_ATTRIB EffectSprite( Coord:cOrigin[ 3 ], POKE_SPRITES:iSprite, Float:fScale = 1.0, Int:iBrightness = 200 )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( TE_SPRITE );
	write_coord( cOrigin[0] );
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] );
	write_short( SPRITE_INDEX[ iSprite ] );
	write_byte( floatround( 10.0 * fScale ) );   // scale in 0.1's
	write_byte( iBrightness );  // brightness
	message_end();
}

/*
	EffectScreenFlash( .iPlayer = id,
						.iRed = 0,
						.iGreen = 0,
						.iBlue = 0,
						.iAlpha = 0,
						.fTime = 0.5,
						.iFadeFlags = ( 1 << 12 )
					);

	iFadeFlags can be the following:
		FFADE_IN			// Just here so we don't pass 0 into the function
		FFADE_OUT			// Fade out (not in)
		FFADE_MODULATE		// Modulate (don't blend)
		FFADE_STAYOUT		// ignores the duration, stays faded out until new ScreenFade message received
*/
PM_FUNC_NORM_ATTRIB EffectScreenFlash( Int:iPlayer, Int:iRed = 0, Int:iGreen = 0, Int:iBlue = 0, Int:iAlpha = 0, Float:fTime = 0.5, Int:iFadeFlags = ( 1 << 12 ) )
{
	if ( PlayerGetInfo( iPlayer, PINFO_BOT ) )
		return;

	message_begin( MSG_ONE_UNRELIABLE, g_msgScreenFade, _, iPlayer );

	write_short( SECONDS_TO_SCREENFADE_UNITS( fTime ) ); //duration
	write_short( SECONDS_TO_SCREENFADE_UNITS( fTime ) ); //holdtime
	write_short( iFadeFlags ); //fade in/out
	write_byte( iRed );
	write_byte( iGreen );
	write_byte( iBlue );
	write_byte( iAlpha );

	message_end();
}

/*
	EffectScreenShake( .iPlayer = id,
						.fAmplitude = 5.0,
						.fDuration = 1.0,
						.fFrequency = 1.0
					);
*/
PM_FUNC_NORM_ATTRIB EffectScreenShake( Int:iPlayer, Float:fAmplitude, Float:fDuration, Float:fFrequency )
{
	if ( PlayerGetInfo( iPlayer, PINFO_BOT ) )
		return;

	message_begin( MSG_ONE_UNRELIABLE, g_msgScreenShake, _, iPlayer );

	write_short( clamp( floatround( fAmplitude * float( 1 << 12 ) ), 0, 0xFFFF ) ); //amplitude
	write_short( clamp( floatround( fDuration * float( 1 << 12 ) ), 0, 0xFFFF ) ); //duration
	write_short( clamp( floatround( fFrequency * float( 1 << 12 ) ), 0, 0xFFFF ) ); //shake noise frequency

	message_end();
}

/*
	EffectBeamEnts( .iPlayer = id,
					.iStartEnt = entity,
					.iEndEnt = entity,
					.iSprite = SPRITE_ROPE,
					.iStartFrame = 0,
					.iFrameRate = 10,
					.fLife = 1.0,
					.iLineWidth = 10,
					.iNoiseAmp = 0,
					.iRed = 255,
					.iGreen = 255,
					.iBlue = 0,
					.iAlpha = 255,
					.iScrollSpeed = 10
				);
*/
PM_FUNC_NORM_ATTRIB EffectBeamEnts( Int:iPlayer, Int:iStartEnt, Int:iEndEnt, POKE_SPRITES:iSprite, Int:iStartFrame = 0, Int:iFrameRate = 10, Float:fLife, Int:iLineWidth, Int:iNoiseAmp = 0, Int:iRed, Int:iGreen, Int:iBlue, Int:iAlpha = 255, Int:iScrollSpeed = 10 )
{
	if ( PlayerGetInfo( iPlayer, PINFO_BOT ) )
		return;

	if ( is_user_alive( iPlayer ) )
		message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, iPlayer );
	else
		message_begin( MSG_BROADCAST, SVC_TEMPENTITY );

	write_byte( TE_BEAMENTS );

	write_short( iStartEnt ); // start entity
	write_short( iEndEnt ); // end entity
	write_short( SPRITE_INDEX[ iSprite ] ); // sprite index
	write_byte( iStartFrame ); // starting frame
	write_byte( iFrameRate ); // frame rate in 0.1's
	write_byte( floatround( fLife * 10.0 ) ); // life in 0.1's
	write_byte( iLineWidth ); // line width in 0.1's
	write_byte( iNoiseAmp ); // noise amplitude in 0.01's
	write_byte( iRed ); // Red
	write_byte( iGreen ); // Green
	write_byte( iBlue ); // Blue
	write_byte( iAlpha ); // brightness
	write_byte( iScrollSpeed ); // scroll speed in 0.1's

	message_end();
}

/*
	EffectBeamEntPoint( .iPlayer = id,
					.iStartEnt = id,
					.cEnd = cEndPos,
					.iSprite = SPRITE_ROPE,
					.iStartFrame = 0,
					.iFrameRate = 10,
					.fLife = 1.0,
					.iLineWidth = 10,
					.iNoiseAmp = 0,
					.iRed = 255,
					.iGreen = 255,
					.iBlue = 0,
					.iAlpha = 255,
					.iScrollSpeed = 10
				);
*/
PM_FUNC_NORM_ATTRIB EffectBeamEntPoint( Int:iPlayer, Int:iStartEnt, Coord:cEnd[3], POKE_SPRITES:iSprite, Int:iStartFrame = 0, Int:iFrameRate = 10, Float:fLife, Int:iLineWidth, Int:iNoiseAmp = 0, Int:iRed, Int:iGreen, Int:iBlue, Int:iAlpha = 255, Int:iScrollSpeed = 10 )
{
	if ( PlayerGetInfo( iPlayer, PINFO_BOT ) )
		return;

	if ( is_user_alive( iPlayer ) )
		message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, iPlayer );
	else
		message_begin( MSG_BROADCAST, SVC_TEMPENTITY );

	write_byte( TE_BEAMENTPOINT );

	write_short( iStartEnt ); // start entity
	write_coord( cEnd[0] ); // end position
	write_coord( cEnd[1] );
	write_coord( cEnd[2] );
	write_short( SPRITE_INDEX[ iSprite ] ); // sprite index
	write_byte( iStartFrame ); // starting frame
	write_byte( iFrameRate ); // frame rate in 0.1's
	write_byte( floatround( fLife * 10.0 ) ); // life in 0.1's
	write_byte( iLineWidth ); // line width in 0.1's
	write_byte( iNoiseAmp ); // noise amplitude in 0.01's
	write_byte( iRed ); // Red
	write_byte( iGreen ); // Green
	write_byte( iBlue ); // Blue
	write_byte( iAlpha ); // brightness
	write_byte( iScrollSpeed ); // scroll speed in 0.1's

	message_end();
}

/*
	EffectBeamPoints( .iPlayer = id,
					.cStart = cStartPos,
					.cEnd = cEndPos,
					.iSprite = SPRITE_ROPE,
					.iStartFrame = 0,
					.iFrameRate = 10,
					.fLife = 1.0,
					.iLineWidth = 10,
					.iNoiseAmp = 0,
					.iRed = 255,
					.iGreen = 255,
					.iBlue = 0,
					.iAlpha = 255,
					.iScrollSpeed = 10
				);
*/
PM_FUNC_NORM_ATTRIB EffectBeamPoints( Int:iPlayer, Coord:cStart[3], Coord:cEnd[3], POKE_SPRITES:iSprite, Int:iStartFrame = 0, Int:iFrameRate = 10, Float:fLife, Int:iLineWidth, Int:iNoiseAmp = 0, Int:iRed, Int:iGreen, Int:iBlue, Int:iAlpha = 255, Int:iScrollSpeed = 10 )
{
	if ( PlayerGetInfo( iPlayer, PINFO_BOT ) )
		return;

	if ( is_user_alive( iPlayer ) )
		message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, iPlayer );
	else
		message_begin( MSG_BROADCAST, SVC_TEMPENTITY );

	write_byte( TE_BEAMPOINTS );

	write_coord( cStart[0] ); // start position
	write_coord( cStart[1] );
	write_coord( cStart[2] );
	write_coord( cEnd[0] ); // end position
	write_coord( cEnd[1] );
	write_coord( cEnd[2] );
	write_short( SPRITE_INDEX[ iSprite ] ); // sprite index
	write_byte( iStartFrame ); // starting frame
	write_byte( iFrameRate ); // frame rate in 0.1's
	write_byte( floatround( fLife * 10.0 ) ); // life in 0.1's
	write_byte( iLineWidth ); // line width in 0.1's
	write_byte( iNoiseAmp ); // noise amplitude in 0.01's
	write_byte( iRed ); // Red
	write_byte( iGreen ); // Green
	write_byte( iBlue ); // Blue
	write_byte( iAlpha ); // brightness
	write_byte( iScrollSpeed ); // scroll speed in 0.1's

	message_end();
}

/*
	EffectBlastCircle( .cOrigin = ,
						.iSprite = SPRITE_SHOCKWAVE,
						.iRadius = 100,
						.fLife = 1.0,
						.iWidth = 10,
						.iNoise = 0,
						.iRed = 255,
						.iGreen = 0,
						.iBlue = 255,
						.iAlpha = 255
					);
*/
PM_FUNC_NORM_ATTRIB EffectBlastCircle( Coord:cOrigin[3], POKE_SPRITES:iSprite = SPRITE_SHOCKWAVE, Int:iRadius, Float:fLife, Int:iWidth, Int:iNoise = 0, Int:iRed, Int:iGreen, Int:iBlue, Int:iAlpha = 255 )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY, cOrigin );

	write_byte( TE_BEAMCYLINDER );

	write_coord( cOrigin[0] );
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] - 16 );
	write_coord( cOrigin[0] );
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] - 16 + iRadius );
	write_short( SPRITE_INDEX[ iSprite ] );
	write_byte( 0 );		// startframe
	write_byte( 0 );		// framerate
	write_byte( floatround( fLife * 10.0 ) )		// life
	write_byte( iWidth );	// width
	write_byte( iNoise );		// noise
	write_byte( iRed );
	write_byte( iGreen );
	write_byte( iBlue );
	write_byte( iAlpha );	//brightness
	write_byte( 0 );		// speed

	message_end();
}

/*
	EffectImplosion( .cOrigin = cOrigin,
					.iRadius = ,
					.iCount = ,
					.fLife = 1.0
				);
*/
PM_FUNC_NORM_ATTRIB EffectImplosion( Coord:cOrigin[ 3 ], Int:iRadius, Int:iCount, Float:fLife = 1.0 )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( TE_IMPLOSION );
	write_coord( cOrigin[0] );
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] );
	write_byte( iRadius );   // radius
	write_byte( iCount );  // how many tracers
	write_byte( floatround( fLife * 10.0 ) )		// life
	message_end();
}

/*
	EffectDLight( .cOrigin = cOrigin,
					.iRadius = ,
					.iRed = 255,
					.iGreen = 255,
					.iBlue = 255,
					.fLife = 1.0,
					.fDecay = 1.0
				);
*/
PM_FUNC_NORM_ATTRIB EffectDLight( Coord:cOrigin[ 3 ], Int:iRadius, Int:iRed, Int:iGreen, Int:iBlue, Float:fLife = 1.0, Float:fDecay = 1.0 )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( TE_DLIGHT );
	write_coord( cOrigin[0] );
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] );
	write_byte( iRadius );   // radius
	write_byte( iRed );
	write_byte( iGreen );
	write_byte( iBlue );
	write_byte( floatround( fLife * 10.0 ) )		// life
	write_byte( floatround( fDecay * 10.0 ) )		// decay rate
	message_end();
}

/*
	EffectBeamFollow( .iEnt = iEnt,
						.iSprite = SPRITE_TRAIL,
						.fLife = 1.0,
						.iWidth = ,
						.iRed = ,
						.iGreen = ,
						.iBlue = ,
						.iBrightness = 
					);
*/
PM_FUNC_NORM_ATTRIB EffectBeamFollow( Int:iEnt, POKE_SPRITES:iSprite = SPRITE_TRAIL, Float:fLife = 1.0, Int:iWidth, Int:iRed, Int:iGreen, Int:iBlue, Int:iBrightness )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( TE_BEAMFOLLOW );				// TE_BEAMFOLLOW
	write_short( iEnt );						// entity:attachment to follow
	write_short( SPRITE_INDEX[iSprite] );		// sprite index
	write_byte( floatround( fLife * 10.0 ) );	// life in 0.1's
	write_byte( iWidth );						// line width in 0.1's
	write_byte( iRed );							// r
	write_byte( iGreen );						// g
	write_byte( iBlue );						// b
	write_byte( iBrightness );					// brightness
	message_end();
}

/*
	EffectSpray( .cOrigin = ,
				.cVelocity = ,
				.iSprite = ,
				.iCount = ,
				.iSpeed = ,
				.iNoise = ,
				.iRenderMode = kRenderTransAdd
				);
*/
PM_FUNC_NORM_ATTRIB EffectSpray( Coord:cOrigin[3], Coord:cVelocity[3], POKE_SPRITES:iSprite, Int:iCount, Int:iSpeed, Int:iNoise, Int:iRenderMode )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( TE_SPRAY );
	write_coord( cOrigin[0] );					//origin
	write_coord( cOrigin[1] );
	write_coord( cOrigin[2] );
	write_coord( cVelocity[0] );				//velocity
	write_coord( cVelocity[1] );
	write_coord( cVelocity[2] );
	write_short( SPRITE_INDEX[ iSprite ] );		//sprite
	write_byte( iCount );						//count
	write_byte( iSpeed );						//speed
	write_byte( iNoise );						//noise
	write_byte( iRenderMode );					//rendermode
	message_end();
}




